home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: undoPageMark.c,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:56:03 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
-
-
- #include "sysdefs.h"
- #include "ess.h"
- #include "checking.h"
- #include "trace.h"
- #include "error.h"
- #include "list.h"
- #include "pool.h"
- #include "tid.h"
- #include "io.h"
- #include "page.h"
- #include "lock.h"
- #include "object.h"
- #include "msgdefs.h"
- #include "thread.h"
- #include "latch.h"
- #include "semaphore.h"
- #include "link.h"
- #include "lsn.h"
- #include "bf.h"
- #include "log.h"
- #include "volume.h"
- #include "logrecs.h"
- #include "openlog.h"
- #include "trans.h"
- #include "bitmap.h"
- #include "undo.h"
- #include "io_extfuncs.h"
- #include "bf_extfuncs.h"
- #include "bm_extfuncs.h"
- #include "log_extfuncs.h"
- #include "undo_extfuncs.h"
- #include "logaction.h"
- #include "util_funcs.h"
- #include "thread_globals.h"
-
-
- void
- undoPageMark (
-
- LOGRECORDHDR *recordHeader
- )
- {
-
- register VOLREC *volRec;
- register PID *pid;
- register GROUPLINK *groupLink;
- register FOUR pageOffset;
- LOGRECORDINFO recordInfo;
- FORCEMARK forceMark;
- LSN lsn;
- LRC *lrc;
- PID bitmapPid;
-
-
- TRPRINT(TR_IO|TR_LOG, TR_LEVEL_1, ("lsn:%d", recordHeader->recordLSN.offset));
-
- /*
- * get a pointer to the name in the record
- */
- pid = (PID *) GET_LOG_IMAGE(recordHeader, 0);
- TRPRINT(TR_IO|TR_LOG, TR_LEVEL_2, ("pid:%d", pid->page));
-
- if ((volRec = io_FindVolRec(pid->volid)) == NULL) {
-
- SM_ERROR(TYPE_FATAL, Active->errno);
- }
-
- /*
- * If debugging is turned on, we should validate that the
- * actionPid matches the bitmap page holding the page in
- * image 0.
- */
- #ifdef DEBUG
-
- /*
- * initialize the pid with the volume
- */
- bitmapPid.volid = volRec->header->volid;
-
- /*
- * calculate the offset to the correct page
- */
- pageOffset = BIT_TO_PAGE(pid->page);
- TRPRINT(TR_IO|TR_LOG, TR_LEVEL_2, ("pageOffset:%d", pageOffset));
-
- /*
- * Check the type to see if we should set any of the bitmaps
- */
- switch (recordHeader->action) {
-
- case LOG_ACTION_MARK_SLOTTED_PAGE:
- case LOG_ACTION_UNMARK_SLOTTED_PAGE:
-
- /*
- * get the pid of the correct slotted bitmap page
- */
- bitmapPid.page = volRec->header->slotBitmapAddr + pageOffset;
- TRPRINT(TR_IO|TR_LOG, TR_LEVEL_2, ("slotted bitmap page:%d", bitmapPid.page));
- break;
-
- case LOG_ACTION_MARK_FILE_PAGE:
- case LOG_ACTION_UNMARK_FILE_PAGE:
-
- /*
- * get the pid of the correct file bitmap page
- */
- bitmapPid.page = volRec->header->fileBitmapAddr + pageOffset;
- TRPRINT(TR_IO|TR_LOG, TR_LEVEL_2, ("fileheader bitmap page:%d", bitmapPid.page));
- break;
-
- default:
-
- SM_ERROR(TYPE_FATAL, esmINTERNAL);
- break;
- }
-
- SM_ASSERT(LEVEL_1, PIDEQ(recordHeader->actionPid, bitmapPid));
-
- #else
-
- /*
- * Debugging is off, so assign the bitmap page to be the actionPid
- */
- bitmapPid = recordHeader->actionPid;
-
- #endif DEBUG
-
- /*
- * read in the page
- */
- if ((groupLink = bf_ReadPage(volRec->bufGroup, &bitmapPid,
- BITMAP_PAGE2SIZE, BF_SEM)) == NULL) {
-
- SM_ERROR(TYPE_FATAL, esmINTERNAL);
- }
-
- /*
- * get the lrc on the bitmap page and increment it
- */
- lrc = &(((BITMAPPAGE *) groupLink->bufFrame)->lrc);
- INCREMENT_LRC(lrc);
-
- /*
- * set the type of the new log record
- */
- switch (recordHeader->action) {
-
- case LOG_ACTION_MARK_SLOTTED_PAGE:
-
- recordInfo.action = LOG_ACTION_UNMARK_SLOTTED_PAGE;
- break;
-
- case LOG_ACTION_UNMARK_SLOTTED_PAGE:
-
- recordInfo.action = LOG_ACTION_MARK_SLOTTED_PAGE;
- break;
-
- case LOG_ACTION_UNMARK_FILE_PAGE:
-
- recordInfo.action = LOG_ACTION_MARK_FILE_PAGE;
- break;
-
- case LOG_ACTION_MARK_FILE_PAGE:
-
- recordInfo.action = LOG_ACTION_UNMARK_FILE_PAGE;
- break;
-
- default:
-
- SM_ERROR(TYPE_FATAL, esmINTERNAL);
- break;
- }
-
- /*
- * initialize the log information
- */
- recordInfo.type = LOG_REC_TYPE_COMPENSATION;
- recordInfo.flags = NOFLAGS;
- recordInfo.imageCount = 1;
- recordInfo.actionPid = &bitmapPid;
- recordInfo.actionLRC = lrc;
- recordInfo.imageSize[0] = sizeof(PID);
- recordInfo.imageData[0] = (VOID *) pid;
- recordInfo.nextUndoLSN = recordHeader->previousLSN;
-
- /*
- * write the record to the log
- */
- if ((forceMark = writeLogRecord((TRANSREC *) Active->transRec,
- &recordInfo, &lsn, NOFLAGS)) < 0) {
-
- SM_ERROR(TYPE_FATAL, Active->errno);
- }
-
- /*
- * check to see if we are to set or unset the bit
- */
- switch (recordInfo.action) {
-
- case LOG_ACTION_UNMARK_FILE_PAGE:
- case LOG_ACTION_UNMARK_SLOTTED_PAGE:
-
- /*
- * clear the bit
- */
- bm_ClearBit((UFOUR *) groupLink->bufFrame, BIT_IN_PAGE(pid->page));
- break;
-
- case LOG_ACTION_MARK_FILE_PAGE:
- case LOG_ACTION_MARK_SLOTTED_PAGE:
-
- /*
- * mark the bit
- */
- bm_SetBit((UFOUR *) groupLink->bufFrame, BIT_IN_PAGE(pid->page));
- break;
-
- default:
-
- SM_ERROR(TYPE_FATAL, esmINTERNAL);
- break;
- }
-
- /*
- * mark the page dependency
- */
- DEPEND_LOG(groupLink->pageHash, forceMark, &lsn, lrc);
-
- /*
- * signal the semaphore
- */
- signalSemaphore( &(groupLink->pageHash->semaphore) );
-
- /*
- * unfix the page
- */
- bf_UnfixPage(groupLink, BF_DEFAULT, TRUE);
- }
-